const mongoose = require('mongoose')
const fs = require('fs')
const path = require('path')

// 数据配置文件
const { host, opts } = require('../../config/db')

// 连接mongodb服务器
mongoose.connect(host, opts).catch(err=>{
  // 连接失败日志记录
  let logpath = path.join(path.dirname(path.dirname(__dirname)),'logs','conn.log')
  fs.appendFileSync(logpath,'aaaa')
})

// 导出mongoose
module.exports = mongoose